import { createSlice } from '@reduxjs/toolkit'
import dayjs from 'dayjs'
export const cityles = createSlice({
    name: 'cityles',
    initialState: {
        start: '北京',
        end: '广州',
        date:dayjs().format('YYYY-MM-DD')
    },
    reducers: {
        cityhh(state) {
            const hh = state.start
            state.start = state.end
            state.end = hh
        },
        citydj(state, { payload:{city,type}}) {
            state[type] = city
        },
        daydate(state,{payload}){
            state.date=payload.date
        }
    }
})
// 每个 case reducer 函数会生成对应的 Action creators
export const { cityhh, citydj,daydate} = cityles.actions

export default cityles.reducer